<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Music/classes/PhpFox_ComponentSearchResults.class.php, $Author:  $ */

 

/** Component for viewing featured musicians
 *   
 * @version $Id: PhpFox_ComponentSearchResults.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.music
 */
class PhpFox_Mod_Music_ComponentSearchResults extends BaseComponent
{
    function process()
    {
        $oMusicService = &$this->_oModule->getService('Music');
        /* @var $oMusicService PhpFox_Mod_Music_ServiceMusic */
        $oSecurityService = &App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
        $oReq = &App::getRequest();

        $oSecurityService->checkPerm('music', array('read_only', 'full'));
        $oSecurityService->checkAccess('music');

        $sValue = $oReq->get('value');
        $sType = $oReq->get('stype');
        $aValFields = array(
            'value' => array('title'=>App::format('Mod_Music.field.search_value'), 'def'=>'required'),
        );
        $oValidator = App::newObject('Validator', $aValFields); 

        $aData = array();
        if( $oValidator->isValid($oReq->getAll()) )
        {
            switch($oReq->getAction())
            {
                case "search":
                    $aData = $oMusicService->search($sValue, $sType);
                    break;
            }
        }
        else
        {
            App::gotoUrl('public.music.index', array(), $oValidator->getErrors(), true, 'Search');
        }       
        
        
        $oTpl = &$this->_oModule->getTemplate();

        $oTpl->assign(array(
            'aData'    => $aData,
            'sValue'   => $sValue,
            'sType'    => $sType,
            'sPicPath' => App::getParam('music.album.pic.url'),
            'bIsStaff' => $oSecurityService->isStaff(),
        )); 
        
        return $oTpl->fetch('SearchResults.html');
    }
}
?>